package com.pc.cloud.services.impl;

import com.pc.cloud.core.SearchHandler;
import com.pc.cloud.services.DocumentBuilder;
import com.pc.cloud.services.SearchArgs;
import com.pc.cloud.services.SearchResults;
import com.pc.cloud.services.SearchServices;

public class LocalSearchServices implements SearchServices {
	private SearchHandler searchHandler = new SearchHandler();

    private static LocalSearchServices searchServices = null;

    public synchronized static LocalSearchServices getInstance(){
        if(searchServices == null){
            searchServices = new LocalSearchServices();
        }
        return searchServices;
    }
	public void init() throws Exception {
		searchHandler.init();
	}
	
	public void index(DocumentBuilder builder) throws Exception {
		searchHandler.index(builder);
		//searchHandler.commit();
	}

	public SearchResults search(SearchArgs args) throws Exception {
		return searchHandler.search(args);
	}
	
	public void close() throws Exception {
		this.searchHandler.close();
	}
}
